package tree;

import tree.data.TreeNode;

import java.util.ArrayList;
import java.util.List;


/**
 * 二叉树的中序遍历
 *
 * https://leetcode.cn/problems/binary-tree-inorder-traversal/submissions/629263362/?envType=study-plan-v2&envId=top-100-liked
 */
public class InorderTraversal {


    List<Integer> l=new ArrayList<>();

    public List<Integer> inorderTraversal(TreeNode root) {

        if (root==null){
            return l;
        }

        if (root.left!=null){
            inorderTraversal(root.left);
        }

        l.add(root.val);

        if (root.right!=null){
            inorderTraversal(root.right);
        }
        return l;
    }


}
